#pragma once
#include "mythread.h"
#include "rscjprops.h"
#include <vector>
#include <iostream>

//	const long double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211;
//	const long double Phi0=2.06783366752e-15;
//	const long double el=1.60217656535e-19;		//Elementary charge
//	const long double hbar=1.05457172647e-34;


class u_t :
	public myThread,public rscjprops
{
public:
	u_t();
	u_t(double Rn,double Ic,double C, double Idc,double U0, double Iac, double w,long double h);
	u_t(double betac, double idc,double u0,double iac, double omega,long double h);
	
	~u_t(void);


	void setIdc(double Idc);
	void setidc(double idc);
	void setU0(long double U0);
	void setu0(long double u0);
	void setsmax(long double smax);
	void seterror(double error);
	void setdeltatmax(double tmax);
	

	double getIdc();
	double getidc();
	double getU();
	double getu();
	long double getU0();
	long double getu0();
	double getuerr();
	long double geth();
	double getsmax();
	void work(void);

	std::vector<long double> t;
	std::vector<long double> v;
	std::vector<long double> phi;


private:

	double Idc;
	double idc;
	double U;
	double u;
	double smax;
	double error;
	long double U0;
	long double u0;
	double utemp;
	long double deltatmax;
	long double deltatmin;
	
	void rk4		(std::vector<long double>& t,std::vector<long double>& v,std::vector<long double>& phi,long double& h);
	void rk4_dynstep(std::vector<long double>& t,std::vector<long double>& v,std::vector<long double>& phi,long double& h);
	void rk5_dynstep(std::vector<long double>& t,std::vector<long double>& v,std::vector<long double>& phi,long double& h);
	void rk4_step	(long double& h,long double& t,long double& v,long double& phi);
	void integrate();
	long double fkt(long double& y,long double& yt);
	long double fkt(long double& t,long double& y,long double& yt);


};

